'use strict';

const Service = require('egg').Service;

class ResourceService extends Service {
    async list(uid) {

        let role = await this.app.mysql.query('select rid from user_role where uid=?',[uid])
        
        let res = await this.app.mysql.query('select res_id from role_resource where rid=?',[role[0].rid])

        let arr = res.map(item => item.res_id);

        let list = await this.app.mysql.query(`select * from resource where id in (${arr})`)

        return list
    }
}

module.exports = ResourceService;
